<html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link type="text/javascript" href="<?php echo Yii::app()->request->baseUrl; ?>/css/scriptbutton.js">
	<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/stylebutton.css" type="text/css">
	<link rel="stylesheet"
		href="<?php echo Yii::app()->request->baseUrl; ?><?php echo Yii::app()->user->getPresentacionRol()?>"
		type="text/css">
	<meta name="viewport"
		content="width-device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0">
	<?php
	$lista=array();
	$conexion=Yii::app()->db;
	$consulta = "SELECT * FROM sucursal ";	
	$resultado=$conexion->createCommand($consulta);
	$files=$resultado->queryAll();
	foreach($files as $file) { 
	$listasucursal=array();
	$nombre=$file['nombre'];
	$coordenadas=$file['coordenadas_direccion'];
	array_push($listasucursal,$nombre);
	array_push($listasucursal,$coordenadas);
	array_push($lista,$listasucursal);
	}


	function lista_sucursales($dato){
	echo "[";
	for ($sucursal=0; $sucursal< count($dato); $sucursal++){
				echo " [";
		if ($sucursal < (count($dato)-1)){
			echo "'";
			echo $dato[$sucursal][0];
			echo "', ";
			echo $dato[$sucursal][1];
			echo "],";
		}
	 	else {
			echo "'";
			echo $dato[$sucursal][0];
			echo "', ";
			echo $dato[$sucursal][1];
			echo "] ]";
			
		}

	}
	}

	?>
	    <style>

	       html, body, #map-canvas {
	         height: 100%; 
	         margin: 0px; 
	         padding: 0px 
	       }
	    </style>
	    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBfKE6Ncy85in6g8TBk7Umskb1EUzd1oMk&sensor=false"></script>
	    <script>

	function initialize() {
	  var mapOptions = {
	    zoom: 12,
	    center: new google.maps.LatLng(-34.774530, -58.267114)
	  }
	  var map = new google.maps.Map(document.getElementById('map-canvas'),
	                                mapOptions);

	  setMarkers(map, beaches);
	}

	var beaches = <?php lista_sucursales($lista);?>

	function setMarkers(map, locations) {

	  var shape = {
	      coords: [1, 1, 1, 20, 18, 20, 18 , 1],
	      type: 'poly'
	  };
	  for (var i = 0; i < locations.length; i++) {
	    var beach = locations[i];
	    var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
	    var marker = new google.maps.Marker({
	        position: myLatLng,
	        map: map,
	    //    icon: image,
	        shape: shape,
	        title: beach[0],
	        zIndex: beach[3]
	    });
	  }
	}

	google.maps.event.addDomListener(window, 'load', initialize);

	    </script>
	</head>

	<body>

	<?php echo CHtml::beginForm(); ?> 
	
			<div class="contenedor">
			<title>Página de inicio</title>

			<table id="cabecera">
				<caption id="titulotabla">
					<img id="imgcab" align="left" src="<?php echo Yii::app()->request->baseUrl; ?>/images/gestiondepacientes.png">
					<h1>GESTION PROFESIONAL</h1>
				</caption>
				<tr>
					<td>
						<h5> <?php $this->widget('ext.popup.JPopupWindow', array(
								'content'=>'Mi Cuenta: '.$cuenta,
								'url'=>$this->createUrl('misdatos'),
								'options'=>array(
									'height'=>430,
									'width'=>980,
									'centerScreen'=>1,
									
								),
								'htmlOptions'=>array(
								   'style'=>"cursor: pointer",
								   
								),
								)); ?>
							<!-- popup -->
						</h5>
					</td>
					<td>
						<h5 value="cerrar sesion" align="right" target="_blank"
							onClick="location.href='<?php echo $this->createUrl('/sesion/logout');?>'"
							style="cursor: pointer">Cerrar Sesión</h5>
					</td>
				</tr>
			</table>			
			<table id="iframe">
				<div>
					<tr>
						<td>&nbsp;</td>
						<td rowspan="12">
							<div id="map-canvas" style="float;width:600px; height:450px"></div>
						</td>
					</tr>
						<tr><td>&nbsp;</td></tr>
						<tr>
						<td><button class="material"><?php $this->widget('ext.popup.JPopupWindow', array(
								'content'=>'Buscador',
								'url'=>$this->createUrl('busqueda'),
								'options'=>array(
									'height'=>530,
									'width'=>1000,
									'centerScreen'=>1,
									
								),
								'htmlOptions'=>array(
								  'style'=>"cursor: pointer",
								 
								),
								)); ?>
								<!-- popup --></button></td>
					</tr>
					<tr>
					
					
					<tr>
						<td><button class="material"><?php $this->widget('ext.popup.JPopupWindow', array(
								'content'=>'Pacientes',
								'url'=>$this->createUrl('/usuario/usuarios'),
								'options'=>array(
									'height'=>530,
									'width'=>1000,
									'centerScreen'=>1,
								),
								'htmlOptions'=>array(
								   //'id'=>'boton',
								   'style'=>"cursor: pointer",
								  
								),
								)); ?>
								<!-- popup --></button></td>
					</tr>
					
					<?php if(Yii::app()->user->esAdmin()){ ?>
					<tr>
						<td><button class="material"><?php $this->widget('ext.popup.JPopupWindow', array(
								'content'=>'Profesionales',
								'url'=>$this->createUrl('/empleado/profesionales'),
								'options'=>array(
									'height'=>580,
									'width'=>1000,
									'centerScreen'=>1,
								),
								'htmlOptions'=>array(
								   //'id'=>'boton',
								   'style'=>"cursor: pointer",
								  
								),
								)); ?>
								<!-- popup --></button></td>
					</tr>
					<tr>
						<td><button class="material"><?php $this->widget('ext.popup.JPopupWindow', array(
								'content'=>'Sucursales',
								'url'=>$this->createUrl('/sucursal/sucursales'),
								'options'=>array(
									'height'=>530,
									'width'=>1000,
									'centerScreen'=>1,
								),
								'htmlOptions'=>array(
									//'id'=>'boton',
								   'style'=>"cursor: pointer",
								
								),
								)); ?>
								<!-- popup --></button></td>
					</tr>
					<tr>
						<td><button class="material"><?php $this->widget('ext.popup.JPopupWindow', array(
								'content'=>'User Pc',
								'url'=>$this->createUrl('/user_pc/userpcs'),
								'options'=>array(
									'height'=>580,
									'width'=>1000,
									'centerScreen'=>1,
								),
								'htmlOptions'=>array(
								   //'id'=>'boton',
								   'style'=>"cursor: pointer",
								   
								),
								)); ?>
								<!-- popup --></button></td>

					</tr>
					<tr>
						<td><button class="material"><?php $this->widget('ext.popup.JPopupWindow', array(
								'content'=>'Estadisticas',
								'url'=>$this->createUrl('/estadistica/estadisticas'),
								'options'=>array(
									'height'=>580,
									'width'=>1000,
									'centerScreen'=>1,
								),
								'htmlOptions'=>array(
								   //'id'=>'boton',
								   'style'=>"cursor: pointer",
								   
								),
								)); ?>
								<!-- popup --></button></td>

					</tr>
					<?php } ?>

						<tr><td>&nbsp;</td></tr>
						<tr><td>&nbsp;</td></tr>
						<tr><td>&nbsp;</td></tr>
					</div>
				</table>
				</div>
			</table>
			
			<a href="<?php echo $this->createUrl('/site/pedido'); ?>" class="pedidos" ></a>

	<?php echo CHtml::endForm(); ?>

	<?php $this->renderPartial('//mensaje/_mensaje'); ?>
			</div>	
		</body>
			</div>

	</body>

</html>